#!/bin/sh
# by hugo

LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
echo '['$LOGTIME'] GFW-List update now.'
echo downloading gfwlist ......
wget-ssl --no-check-certificate https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt -O /tmp/gfw.b64
echo deal the list......
/usr/bin/ssr-gfw
icount=$(cat /tmp/gfwnew.txt | wc -l)
oldcount=$(cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l)
echo old GFW-List count: $oldcount
echo new GFW-List count: $icount
if [ $icount -ne $oldcount ]; then
	cp -f /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf
	echo "Update GFW-List Done!"
	/etc/init.d/shadowsocksr restart
else
	echo "GFW-List No Change!"
fi
rm -f /tmp/gfwnew.txt
